<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8" />
		<title>荷芯联盟答题PK</title>
		<meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-scale=1.0' />
		<link rel="stylesheet" href="css/answerPk.css" />
		<script src="js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/moduls/islogin.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/moduls/alliance.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/moduls/pk.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript" src="js/adapter.js"></script>
		<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>

	</head>

	<body>
		<div class="content">
			<div class="logo">
				<img src="img/logo.png" />
			</div>
			<div class="theme">
				<img src="img/theme.png" />
			</div>
			<div class="subTop">
				<div class="picture">
					<img src="img/title2.png" />
				</div>
				<div class="right_items">
					<div class="record">我的PK记录</div>
				</div>
			</div>
			<div class="back">
				<div class="backBtn">
					<a href="javascript:history.go(-1)"><img src="img/closeBtn.png" alt=""></a>
				</div>

			</div>
			<div class="middlePath">
				<div class="title">
					<img src="img/answerPK/answerPk.png" alt="">
					<div id="alliName" style="width:100%;font-size: 0.36rem;height: 0.36rem;line-height: 0.36rem; color: #f7dc6a;margin: 0.1rem 0; font-weight: bold;font-family: '微软雅黑';">
						<!--<span>**</span>
						<span>联盟</span>-->{{teamInfos.name}}
					</div>
				</div>
				<div class="line">
					<img src="img/line.png" alt="">
				</div>
				<div class="midContent">
					<div class="teamInfo">
						<div class="honorVal">{{teamInfos.honor}}荣誉值</div>
						<div class="rank">排名：{{teamInfos.rownum}}</div>
						<div class="area">地区：{{teamInfos.address}}</div>
					</div>
					<div class="line">
						<img src="img/line.png" alt="">
					</div>
					<div class="brief">
						<!--<span>我的</span>-->
						<div class="captainImg"><img :src="myInfo.avatar" style="border-radius: 50%;"></div>
						<div class="captain">
							<span>{{myInfo.name}} </span>
							<span>{{myInfo.lotusNum}}荷花</span>
						</div>
						<div class="teamNum">
							<span>队伍</span>
							<span>**</span>名
						</div>
					</div>
					<div class="line">
						<img src="img/line.png" alt="">
					</div>

				</div>

				<div class="challenge">
					<div class="sendBtn">我发起的</div>
					<div class="acceptBtn">挑战我的</div>
				</div>
				<div class="persons">
					<div class="chanPerson" v-for="(person,index) in pkUsers" :key="index">
						<div class="item" @click="checkUser(index)">
							<img :src="person.avatar" />
							<div class="chanBtn">
								{{checked[index]==1?"已选择":"选TA挑战"}}
							</div>
							<!--<div class="chanBtn" v-show="checked[index]?true:false">
							选TA挑战
						</div>-->
						</div>

					</div>

				</div>

				<div class="bottomBtn">
					<div class="choose startChallenge">发起挑战</div>
					<div class="choose friendChallenge">选择朋友挑战</div>
					<div class="refresh">
						<a >刷新一下</a>

					</div>
				</div>
				<div class="bottom-logo">
					<img src="img/bottom_logo2.png" />
				</div>
			</div>
		</div>
		<script type="text/javascript">
			var app = new Vue({
				el: '.content',
				data: {
					myInfo:[],
					teamUsers: [],
					teamInfos: [],
					pkUsers: [],
					checked: [],
					checkedUser: []
				},
				methods: {
					checkUser(_index) {
						if(this.checked[_index]) {
							Vue.set(this.checked, _index, 0)
						} else {
							Vue.set(this.checked, _index, 1)
						}

						console.log(this.checked)
					}
				}
			})

			//获取自己联盟信息
			getMyTeam(t_skey, function(_res) {
				app.teamUsers = _res.teamUsers;
				app.teamInfos = _res.teamInfo;
				for (var i=0;i<_res.teamUsers.length;i++) {
					if(_res.teamUsers[i]["uid"]==window.localStorage.getItem("uid")){
						app.myInfo=_res.teamUsers[i];
					}		
				}
				$(".content").css("opacity", 1);
				

			})
			//获取pk对手
			getPkUser(t_skey, function(_res) {
				app.pkUsers = _res.data;
				for(var i = 0; i < _res.data.length; i++) {
					app.checked[i] = 0
				}
				$(".content").css("opacity", 1);

			})
			

			//选择朋友挑战
			$(".friendChallenge").click(function() {
				//				console.log("选择朋友挑战")
				var t_manner = "好友pk";
				alert("选择朋友挑战")
			})
			
			//发起挑战
			$(".startChallenge").click(function(){
				if(app.checked.length > 10){
					alert("您最多只能选择10个人进行本次挑战！");return
				}
				
				app.checkedUser = [];
				for(var i = 0; i < app.checked.length; i++) {
					if(app.checked[i] == 1) {
						app.checkedUser.push(app.pkUsers[i]["uid"]);
					}
					var t_manner = "联盟pk";
					var t_rivaIds = app.checkedUser;
					window.localStorage.setItem("rivaIds",t_rivaIds);
					window.location.href= "answerPk.html?manner="+t_manner;
				}
			})

			//刷新一下
			$(".refresh").click(function() {
				console.log(app.pkUsers);
				app.pkUsers = [];
				for(var i = 0; i < app.checked.length; i++) {
					app.checked[i] = 0;
				}
				console.log(app.pkUsers)

				getPkUser(t_skey, function(_res) {
					app.pkUsers = _res.data;
				})
			})
		</script>
		<script src="js/answerPk.js" type="text/javascript" charset="utf-8"></script>
	</body>

</html>